//
//  Storage.swift
//  Storage
//
//  Created by ak on 2018/2/24.
//

import Foundation

public struct Storage {
    public static func save(_ value: Any, forKey: String) {
        UserDefaults.standard.set(value, forKey: forKey)
    }
    
    public static func delete(forKey: String) {
        UserDefaults.standard.set(nil, forKey: forKey)
    }
    
    public static func value(forKey: String) -> Any? {
        return UserDefaults.standard.object(forKey: forKey)
    }
    
    public static func dictionary(forKey: String) -> [String: Any]? {
        return UserDefaults.standard.dictionary(forKey:forKey)
    }
    
    public static func data(forKey: String) -> Data? {
        return UserDefaults.standard.data(forKey:forKey)
    }

    public static func string(forKey: String) -> String? {
        return UserDefaults.standard.string(forKey:forKey)
    }
    
    public static func array(forKey: String) -> Array<Any>? {
        return UserDefaults.standard.array(forKey:forKey)
    }
    
    public static func stringArray(forKey: String) -> [String]? {
        return UserDefaults.standard.stringArray(forKey:forKey)
    }
    
    public static func bool(forKey: String) -> Bool {
        return UserDefaults.standard.bool(forKey:forKey)
    }
    
    public static func int(forKey: String) -> Int {
        return UserDefaults.standard.integer(forKey:forKey)
    }
    
    public static func float(forKey: String) -> Float {
        return UserDefaults.standard.float(forKey:forKey)
    }
}
